

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;

using JTC.MiniCommerce.Localization.resources;

namespace JTC.MiniCommerce.Localization {

  public class LocalizationUtility {
  
    #region Methods
    
    #region Public

    /// <summary>
    /// Adds the hover help.
    /// </summary>
    /// <param name="hyperlink">The hyperlink.</param>
    public static void AddHoverHelp(HyperLink hyperlink) {
      string helpText = help.noHelp;
      helpText = string.IsNullOrEmpty(help.ResourceManager.GetString(hyperlink.ID)) ? help.noHelp : help.ResourceManager.GetString(hyperlink.ID);
      hyperlink.Attributes.Add("onmouseover", string.Format(Overlib.TOOLTIP, helpText));
      hyperlink.Attributes.Add("onmouseout", Overlib.MOUSEOUT);
    }

    /// <summary>
    /// Adds the hover HTML.
    /// </summary>
    /// <param name="hyperlink">The hyperlink.</param>
    /// <param name="html">The HTML.</param>
    public static void AddHoverHtml(HyperLink hyperlink, string html) {
      hyperlink.Attributes.Add("onmouseover", string.Format(Overlib.SIMPLE, html));
      hyperlink.Attributes.Add("onmouseout", Overlib.MOUSEOUT);
    }

    /// <summary>
    /// Adds the label text.
    /// </summary>
    /// <param name="label">The label.</param>
    public static void AddLabelText(Label label) {
      label.Text = labels.ResourceManager.GetString(label.ID);
    }

    /// <summary>
    /// Adds the panel text.
    /// </summary>
    /// <param name="panel">The panel.</param>
    public static void AddPanelText(Panel panel) {
      panel.GroupingText = labels.ResourceManager.GetString(panel.ID);
    }

    /// <summary>
    /// Adds the button text.
    /// </summary>
    /// <param name="button">The button.</param>
    public static void AddButtonText(Button button) {
      button.Text = labels.ResourceManager.GetString(button.ID);
    }

    /// <summary>
    /// Adds the link button text.
    /// </summary>
    /// <param name="linkButton">The link button.</param>
    public static void AddLinkButtonText(LinkButton linkButton) {
      linkButton.Text = labels.ResourceManager.GetString(linkButton.ID);
    }

    /// <summary>
    /// Adds the checkbox text.
    /// </summary>
    /// <param name="checkBox">The check box.</param>
    public static void AddCheckboxText(CheckBox checkBox) {
      checkBox.Text = labels.ResourceManager.GetString(checkBox.ID);
    }

    /// <summary>
    /// Adds the hyper link text.
    /// </summary>
    /// <param name="hyperLink">The hyper link.</param>
    public static void AddHyperLinkText(HyperLink hyperLink) {
      hyperLink.Text = labels.ResourceManager.GetString(hyperLink.ID);
    }

    /// <summary>
    /// Adds the RFV error message text.
    /// </summary>
    /// <param name="requiredFieldValidator">The required field validator.</param>
    public static void AddRfvErrorMessageText(RequiredFieldValidator requiredFieldValidator) {
      requiredFieldValidator.ErrorMessage = labels.ResourceManager.GetString(requiredFieldValidator.ID);
    }

    /// <summary>
    /// Adds the image alternate text.
    /// </summary>
    /// <param name="image">The image.</param>
    public static void AddImageAlternateText(System.Web.UI.WebControls.Image image) {
      image.AlternateText = labels.ResourceManager.GetString(image.ID);
    }

    /// <summary>
    /// Gets the text.
    /// </summary>
    /// <param name="name">The name.</param>
    /// <returns></returns>
    public static string GetText(string name) {
      return labels.ResourceManager.GetString(name);
    }

    /// <summary>
    /// Gets the store string.
    /// </summary>
    /// <param name="name">The name.</param>
    /// <returns></returns>
    public static string GetStoreString(string name) {
      return Strings.ResourceManager.GetString(name);
    }

    /// <summary>
    /// Gets the critical message text.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <returns></returns>
    public static string GetCriticalMessageText(string message) {
      return string.Format(GetText("lblCriticalError"), message);
    }
    
    #endregion
    
    #endregion
      
  }
}
